using System;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace Horizon
{
    [Serializable]
    public class HorizonSession
    {
        private string sessionIdValue;
        private Library libraryValue;
        private CookieContainer cookiesValue = new CookieContainer();
        private bool loggedInValue = false;

        /// <summary>
        /// Indicates if the user is logged in.  Note that this does not indicate that
        /// the session is valid.  If a session times out, then this flag will be
        /// incorrect.  Login in the Libray class checks for this condition to auto
        /// login if necessary.
        /// </summary>
        public bool LoggedIn
        {
            get { return loggedInValue; }
            set { loggedInValue = value; }
        }

        /// <summary>
        /// Mark the session as invalid.  Note that this should really be called as 
        /// part of a logoff, but it's not strictly necessary.
        /// </summary>
        public void Invalidate()
        {
            cookiesValue = new CookieContainer();
            sessionIdValue = null;
            loggedInValue = false;
        }

        /// <summary>
        /// HTTP request cookies used to maintain session information
        /// </summary>
        public CookieContainer Cookies
        {
            get { return cookiesValue; }
            set { cookiesValue = value; }
        }

        /// <summary>
        /// Library associated with this session
        /// </summary>
        public Library SessionLibrary
        {
            get { return libraryValue; }
            set { libraryValue = value; }
        }

        /// <summary>
        /// Session identifier string (i.e. 117I06765W046.518)
        /// </summary>
        public string SessionKey
        {
            get { return sessionIdValue; }
            set { sessionIdValue = value; }
        }
    }
}
